package com.ruoyi.system.enumeration;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * 代表 sy_ticket_duration_cards 表中 type 字段的枚举类型
 */
@ApiModel("充值卡/券类型枚举")
public enum TicketTypeEnum {

    TABLE_DURATION_CARD(0, "桌台时长卡"),
    TABLE_VISIT_CARD(1, "桌台次卡"),
    PRODUCT_VISIT_CARD(2, "商品次卡"),
    VOUCHER(3, "代金券");

    private final int value;
    private final String description;

    TicketTypeEnum(int value, String description) {
        this.value = value;
        this.description = description;
    }

    @ApiModelProperty("类型编码")
    public int getValue() {
        return value;
    }

    @ApiModelProperty("类型描述")
    public String getDescription() {
        return description;
    }

    /**
     * 根据值获取描述
     */
    public static String getDescriptionByValue(int value) {
        for (TicketTypeEnum type : TicketTypeEnum.values()) {
            if (type.getValue() == value) {
                return type.getDescription();
            }
        }
        return null;
    }

    /**
     * 根据描述获取值
     */
    public static Integer getValueByDescription(String description) {
        for (TicketTypeEnum type : TicketTypeEnum.values()) {
            if (type.getDescription().equals(description)) {
                return type.getValue();
            }
        }
        return null;
    }
}
